import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { DeptForm, DeptQuery, DeptVO } from "./types";

/**
 * 部门树形表格
 *
 * @param queryParams
 */
export function listDepts(
  queryParams?: DeptQuery
): AxiosPromise<TreeResult<DeptVO>[]> {
  return request({
    url: "admin/dept/tree",
    method: "get",
    params: queryParams,
  });
}

/**
 *  修改部门
 *
 * @param id
 * @param data
 */
export function saveDept(data: DeptForm) {
  return request({
    url: "admin/dept/save",
    method: "post",
    data,
  });
}

/**
 * 删除部门
 *
 * @param ids
 */
export function deleteDept(ids: string[]) {
  return request({
    url: "admin/dept/del",
    method: "post",
    data: ids,
  });
}
